import datetime
import random
import time


def get_ip(request):
    if 'HTTP_X_FORWARDED_FOR' in request.META:
        ip = request.META.get('HTTP_X_FORWARDED_FOR')
    else:
        ip = request.META.get('REMOTE_ADDR')

    return ip


def get_json_values(key, data, default=None):
    ret = data.get(key, default)
    return ret


def get_time_uuid():
    """
        :return: 20220525140635467912
        :PS ：并发较高时尾部随机数增加
    """
    order_id = str(datetime.datetime.fromtimestamp(time.time())).replace("-", "").replace(" ", "").replace(":","").replace(".", "") + str(random.randint(100, 999))
    return order_id

if __name__ == "__main__":

    print(get_time_uuid())





